package com.cyc.basic.test.other;

/**
 * @author chenyunchang
 * @title
 * @date 2020/12/31 9:52
 * @Description: 判断字符串是否回文
 */
public class Palindrome {
    public static void main(String[] args) {
        String s1 = "aabbccdd";
        String s2 = "aabbaa";
        isPalindrome(s1);
        isPalindrome(s2);
    }

    private static void isPalindrome(String s) {
        StringBuilder sb = new StringBuilder(s);
        String afterReverse = sb.reverse().toString();
        int isEqual = afterReverse.compareTo(s);
        if (isEqual == 0) {
            System.out.println(s + " 是回文");
        } else {
            System.out.println(s + " 不是回文");
        }
    }
}